<!-- 카메라 페이지(기능 미구현) -->
<div data-role="page">
	<div data-role="header" data-theme="b" data-position="fixed">
		<a href="/" data-icon="home" class="ui-btn-left">Home</a>
		<h1>Write TAG</h1>
		<a href="#" data-icon="refresh">Refresh</a>
	</div>

	<h1>Camera API Test</h1>

	<section class="main-content">
		<p>Choose to take a picture with your device's camera and a
			preview will be shown through createObjectURL or a FileReader object
			(choosing local files supported too).</p>

		<p>
			<input type="file" id="take-picture" accept="image/*">
		</p>

		<h2>Preview:</h2>
		<p>
			<img src="about:blank" alt="" id="show-picture">
		</p>

		<p id="error"></p>

	</section>

	<!--  <p class="footer">All the code is available in the <a href="https://github.com/robnyman/robnyman.github.com/tree/master/camera-api">Camera API repository on GitHub</a>.</p>  -->
</div>


<script type="text/javascript">
        (function () {
            var takePicture = document.querySelector("#take-picture"),
                showPicture = document.querySelector("#show-picture");

            if (takePicture && showPicture) {
                // Set events
                takePicture.onchange = function (event) {
                    // Get a reference to the taken picture or chosen file
                    var files = event.target.files,
                        file;
                    if (files && files.length > 0) {
                        file = files[0];
                        try {
                            // Get window.URL object
                            var URL = window.URL || window.webkitURL;

                            // Create ObjectURL
                            var imgURL = URL.createObjectURL(file);

                            // Set img src to ObjectURL
                            showPicture.src = imgURL;

                            // Revoke ObjectURL
                            URL.revokeObjectURL(imgURL);
                        }
                        catch (e) {
                            try {
                                // Fallback if createObjectURL is not supported
                                var fileReader = new FileReader();
                                fileReader.onload = function (event) {
                                    showPicture.src = event.target.result;
                                };
                                fileReader.readAsDataURL(file);
                            }
                            catch (e) {
                                //
                                var error = document.querySelector("#error");
                                if (error) {
                                    error.innerHTML = "Neither createObjectURL or FileReader are supported";
                                }
                            }
                        }
                    }
                };
            }
        })();
        </script>